package clone;

import com.alibaba.fastjson.JSONObject;

public class CloneTest{
	
	public static void main(String[] args){
		Person a = new Person("a");
		Person b = a.clone();
		b.setName("b");
		Person c = a.clone();
		c.setName("c");
		System.out.println(JSONObject.toJSONString(a));
		System.out.println(JSONObject.toJSONString(b));
		System.out.println(JSONObject.toJSONString(c));
	}
}

class Person implements Cloneable{
	
	private String[] name = new String[1];

	public Person(String name) {
		this.name[0] = name;
	}
	
	public void setName(String name) {
		this.name[0] = name;
	}
	
	public String[] getName() {
		return name;
	}
	
	public void setName(String[] name) {
		this.name = name;
	}
	
	@Override
	public Person clone() {
		try {
			return (Person)super.clone();
		} catch (CloneNotSupportedException e) {
			e.printStackTrace();
		}
		return null;
	}
}